import request from '@utils/request'

// 查询角色信息列表
export function getRoleList (data) {
  return request({
    url: '/merchantRole/getPageLit',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 选择PC端角色
export function getRoles (data) {
  return request({
    url: '/merchantRole/getRoleList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 新增角色信息
export function addNewRole (data) {
  return request({
    url: '/merchantRole/newRole',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 修改角色信息
export function changeRole (data) {
  return request({
    url: '/merchantRole/editRole',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除角色信息
export function deleteRole (query) {
  return request({
    url: '/merchantRole/remove',
    method: 'post',
    params: query,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 设置角色菜单权限
export function saveRoleMenu (data) {
  return request({
    url: '/merchantRole/saveRoleMenu',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 根据角色Id获取菜单Id列表
export function getMenuByRoleId (query) {
  return request({
    url: '/merchantRole/getMenuByRoleId',
    method: 'post',
    params: query,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}